/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.kota105.ui.generic;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author pikpun
 */
public abstract class AbstractLayout extends AbstractWidget implements Layout {

    public List<Widget> widgets;
    public List<Layout> layouts;

    public AbstractLayout() {
        widgets = new ArrayList<Widget>();
        layouts = new ArrayList<Layout>();
    }

    public List<Widget> getWidgets() {
        return widgets;
    }

    public void addWidget(Widget widget) {
        widgets.add(widget);
    }

    public void removeWidget(Widget widget) {
        widgets.remove(widget);
    }

    public void removeAllWidget() {
        widgets = new ArrayList<Widget>();
    }

    public Widget getWidget(String xmlName) {
        for (int i = 0; i < widgets.size(); i++) {
            if (widgets.get(i).getXMLName().equals(xmlName)) {
                return widgets.get(i);
            }
        }
        return null;
    }

    public void setRoot(Boolean isRoot) {
        this.isRoot = isRoot;
    }

    public boolean isRoot() {
        return isRoot;
    }
}
